package com.laker.admin.module.excel.controller;

import com.laker.admin.framework.aop.Metrics;
import com.laker.admin.framework.model.Response;
import com.laker.admin.module.excel.domain.ExcelTemplate;
import com.laker.admin.module.excel.entity.ExcelTemplateCmd;
import com.laker.admin.module.excel.facade.ExcelTemplateFacade;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * excel模版
 * </p>
 *
 * @author nihongxin
 * @since 2021-12-08
 */
@RestController
@RequestMapping("/excelTemplate")
@Metrics
public class ExcelTemplateController {

    @Autowired
    private ExcelTemplateFacade excelTemplateFacade;

    @PostMapping("/save")
    @ApiOperation(value = "保存数据")
    public Response save(@RequestBody ExcelTemplate excelTemplate) {
        return excelTemplateFacade.save(excelTemplate);
    }

    @GetMapping("/saveWfProcessName")
    @ApiOperation(value = "关联工作流")
    public Response saveWfProcessName(Long id, String wfProcessName) {
        return excelTemplateFacade.saveWfProcessName(id, wfProcessName);
    }


    @ApiOperation(value = "查询模版列表")
    @PostMapping(value = "/list")
    public Response list(@RequestBody ExcelTemplateCmd excelTemplateCmd) {
        return excelTemplateFacade.list(excelTemplateCmd);
    }

    @ApiOperation(value = "根据用户信息查询模版列表")
    @PostMapping(value = "/listByUser")
    public Response listByUser(@RequestBody ExcelTemplateCmd excelTemplateCmd) {
        return excelTemplateFacade.listByUser(excelTemplateCmd);
    }

    @ApiOperation(value = "获取单个数据")
    @GetMapping(value = "/getById/{id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "Long", required = true, value = "主键id", paramType = "form")
    })
    public Response getById(@PathVariable Long id) {
        return excelTemplateFacade.getById(id);
    }

    @ApiOperation(value = "删除数据")
    @DeleteMapping(value = "/deleteById/{id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "Long", required = true, value = "主键id", paramType = "form")
    })
    public Response deleteById(@PathVariable Long id) {
        return excelTemplateFacade.deleteById(id);
    }

}